Skip to content

test(protect): per-vuln-class rule corpus + rename example-rule test - #91

Merged
patchstackdave merged 1 commit into
mainfrom
test/protect-rule-coverage
Jul 16, 2026
Merged

test(protect): per-vuln-class rule corpus + rename example-rule test#91
patchstackdave merged 1 commit into
mainfrom
test/protect-rule-coverage

Conversation

@patchstackdave

Copy link
Copy Markdown
Contributor

Two rule-test changes:

1. rule-corpus.test.ts — end-to-end coverage per vuln class. Canonical vpatch rules run through the real request path (fetchGuardfromFetchRequest → engine), not a hand-shaped engine object. Each class pairs an exploit (must block) with a benign request (must pass — the false-positive guard): prototype pollution, path traversal, SQLi, reflected XSS (inline_xss), command injection, request-side SSRF (internal_host), NoSQL, scanner User-Agent (server.HTTP_*), malicious cookie (cookie.*), and a base64 mutation chain. Plus dry-run (detect, don't block), inclusive AND, and whitelist suppression — all end-to-end. Complements the engine-primitive unit tests (which call evaluate() on pre-shaped objects).

2. Rename dave-example-rule.test.tsexample-rule.test.ts and drop the personal name from its titles — test names shouldn't carry individuals' names.

+23 tests. Tests only.

Add tests/protect/rule-corpus.test.ts: canonical vpatch rules (one per vuln class — prototype
pollution, path traversal, SQLi, XSS/inline_xss, command injection, request-side SSRF/internal_host,
NoSQL, scanner UA, malicious cookie, base64 mutation chain) run END-TO-END through fetchGuard (real
Request → shaping → engine), each pairing an exploit (must block) with a benign request (must not —
false-positive guard). Plus dry-run detect-not-block, inclusive AND, and whitelist suppression
end-to-end. Complements the engine-primitive unit tests, which evaluate hand-shaped objects.

Also rename dave-example-rule.test.ts → example-rule.test.ts and drop the personal name from its
titles (test names shouldn't carry individuals' names). +23 tests, 518 total.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderbuds

coderbuds Bot commented Jul 16, 2026

Copy link
Copy Markdown

Thorough end-to-end test corpus covers each vulnerability class with clear exploit and benign cases.

🎯 Quality: 100% Elite · 📦 Size: Medium

📈 This month: Your 40th PR — above team average · Averaging Excellent

See how your team is trending →

@patchstackdave

Copy link
Copy Markdown
Contributor Author

/review

@patchstackdave
patchstackdave merged commit 31e61ec into main Jul 16, 2026
4 checks passed
@patchstackdave
patchstackdave deleted the test/protect-rule-coverage branch July 16, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants